package com.fafa.swing.base;

import javax.swing.*;
import java.awt.*;

/**
 * @author : fafa
 * @version V1.0
 * @Project: SwingTest
 * @Package com.fafa.swing
 * @Description: CardLayoutDemo
 * @date Date : 2019年11月23日 11:15
 */
public class CardLayoutDemo extends JFrame {
    public static void main(String[] args) {
        JFrame jFrame = new JFrame("第五个GUI窗口程序CardLayoutDemo");
        JPanel jp1 = new JPanel();
        JPanel jp2 = new JPanel();
        JPanel cards = new JPanel(new CardLayout());    //卡片式布局的面板
        jp1.add(new JButton("登录按钮"));
        jp1.add(new JButton("注册按钮"));
        jp1.add(new JButton("找回密码按钮"));
        jp2.add(new JTextField("用户名文本框",20));
        jp2.add(new JPasswordField("用户密码文本框",20));
        jp2.add(new JTextField("验证码",20));
        cards.add(jp1,"card1");
        cards.add(jp2,"card2");
        CardLayout cardLayout = (CardLayout) cards.getLayout();
        cardLayout.show(cards,"card2"); //调用show()方法显示面板2
        jFrame.add(cards);
        jFrame.setBounds(300,200,400,200);
        jFrame.setVisible(true);
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
